package com.ooqiu.gaming.db;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.alibaba.fastjson.annotation.JSONField;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;

/**
 * @author Eenie
 * @date 2017/11/17
 * 每一个模块的分类：首页的推荐、热门等
 */


@Entity(nameInDb = "channel")
public class Channel implements Parcelable {
    public static final int MODULE_ID_INDEX = 1;
    public static final int MODULE_ID_VIDEO = 2;

    @Id(autoincrement = true)
    private Long _id;


    private String cat_id;

    @JSONField(name = "id")
    private String real_id;

    private String typename;

    private int modoule_id;
    private boolean show;
    private String user_token;


    protected Channel(Parcel in) {
        if (in.readByte() == 0) {
            _id = null;
        } else {
            _id = in.readLong();
        }
        cat_id = in.readString();
        typename = in.readString();
        modoule_id = in.readInt();
        show = in.readByte() != 0;
    }


    @Generated(hash = 459652974)
    public Channel() {
    }


    @Generated(hash = 345844973)
    public Channel(Long _id, String cat_id, String real_id, String typename,
            int modoule_id, boolean show, String user_token) {
        this._id = _id;
        this.cat_id = cat_id;
        this.real_id = real_id;
        this.typename = typename;
        this.modoule_id = modoule_id;
        this.show = show;
        this.user_token = user_token;
    }




    public static final Creator<Channel> CREATOR = new Creator<Channel>() {
        @Override
        public Channel createFromParcel(Parcel in) {
            return new Channel(in);
        }

        @Override
        public Channel[] newArray(int size) {
            return new Channel[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        if (_id == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeLong(_id);
        }
        dest.writeString(cat_id);
        dest.writeString(typename);
        dest.writeInt(modoule_id);
        dest.writeByte((byte) (show ? 1 : 0));
    }

    public Long get_id() {
        return this._id;
    }

    public void set_id(Long _id) {
        this._id = _id;
    }

    public String getCat_id() {
        return TextUtils.isEmpty(this.cat_id) ? this.real_id : this.cat_id;
    }

    public void setCat_id(String cat_id) {
        this.cat_id = cat_id;
    }

    public String getTypename() {
        return this.typename;
    }

    public void setTypename(String typename) {
        this.typename = typename;
    }

    public int getModoule_id() {
        return this.modoule_id;
    }

    public void setModoule_id(int modoule_id) {
        this.modoule_id = modoule_id;
    }

    public boolean getShow() {
        return this.show;
    }

    
    public void setShow(boolean show) {
        this.show = show;
    }



    public String getUser_token() {
        return this.user_token;
    }

    public void setUser_token(String user_token) {
        this.user_token = user_token;
    }


    public String getReal_id() {
        return TextUtils.isEmpty(this.real_id) ? this.cat_id : this.real_id;
    }


    public void setReal_id(String real_id) {
        this.real_id = real_id;
    }


 
}
